package com.asiainfo.fc.action;

import java.util.ArrayList;

import com.asiainfo.fc.data.DataHelper;
import com.asiainfo.fc.db.DBHelper;
import com.asiainfo.fc.entity.ProxyInfo;
import com.asiainfo.fc.entity.VoteInfo;
import com.asiainfo.fc.net.NetHelper;

public class UpdateVoteAction {

	/**
	 * 
	 * @param url
	 * @return
	 */
	public boolean updateVote(String url) {
		NetHelper netHelper = new NetHelper();
		// gzproxy.asiainfo-linkage.com
		ProxyInfo proxyInfo = DBHelper.getInstance().getProxy();
		if (proxyInfo != null) {
			netHelper.setUserProxy(proxyInfo.getIsuse() == 1);
			netHelper.setProxyHost(proxyInfo.getProxyHost());
			netHelper.setProxyPort(proxyInfo.getProxyPort());
		}
		String strData = netHelper.downLoadByGet(url);
		if (strData != null) {
			DataHelper data = new DataHelper();
			ArrayList<VoteInfo> voteInfoList = data.getVoteList(strData);
			return DBHelper.getInstance().updateDb(voteInfoList);
		}
		return false;

	}

}
